<template>
    <div class="movie willhot">
        <div class="top">
            <div class="will">即将上映</div>
        </div>
        <div class="com upmovie">
            <ul>
                <li v-for="item in willhotList">
                    <router-link :to="{name:'detail',params:{'id':item.id}}">
                        <div><img :src="item.cover.origin" alt=""></div>
                        <div class="desc clear">
                            <div class="txt fl">
                                <p class="title">{{item.name}}</p>
                            </div>
                            <div class="time fr"><span>{{item.month}}</span>月<span>{{item.day}}</span>日上映</div>
                        </div>						
                    </router-link>
                </li>
            </ul>
        </div>		
        <div class="more">
            <router-link :to="{name:'soon'}" class="text">更多即将上映电影</router-link>        
        </div>
    </div>
</template>

<script>
    import $ from 'jquery';
    export default{
        data:function(){
            return{
                willhotList:[]
            }
        },
        mounted:function(){
            var self=this;
            var now=new Date().getTime();
            // ajax请求得到即将上映信息
            $.get('http://localhost:3000/willhot?time='+now,function(res){
                var arr=res.data.films;
                for(var i=0;i<arr.length;i++){
                    var date=new Date(arr[i]['premiereAt']);
                    var month=date.getMonth()+1;
                    var day=date.getDate();
                    arr[i].month=month;
                    arr[i].day=day;
                }
                self.willhotList=arr;
            })			 	
        }
    }
</script>